package com.in.mobilerechargedth;

import java.util.ArrayList;
import java.util.List;

import com.in.mobilerechargedth.adapter.SixthTransponderDetailScreenListViewAdapter;
import com.in.mobilerechargedth.constant.ConstantVariables;
import com.in.mobilerechargedth.model.TransponderModel;

import android.os.Bundle;

import android.view.View;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;

public class SixthTransponderDetailScreenActivity extends BaseActivity {

    List<TransponderModel> transponderDetails;
    ListView lvDetail;
    TextView txtEmpty;
    int operatorId = 0;
    Button backbtn;

    List<TransponderModel> listTransponderModel;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_fourth_recharge_detail_screen);
        String frequency = getIntent().getStringExtra(
                ConstantVariables.FREQUENCY_NAME);
        String strOperatorId = getIntent().getStringExtra(ConstantVariables.OPERATOR_ID);
        operatorId = Integer.parseInt(strOperatorId);
        transponderDetails = new ArrayList<TransponderModel>();
        backbtn = (Button) findViewById(R.id.backbtn);
        backbtn.setVisibility(View.VISIBLE);
        backbtn.setOnClickListener(this);
        listTransponderModel = SixthScreenActivity.listTransponderModel;


        for (TransponderModel transponderModel : listTransponderModel) {
            if (frequency.equals(transponderModel.getFrequency()) && operatorId == transponderModel.getOperatorId()) {
                TransponderModel detail = new TransponderModel();
                detail.setFrequency(transponderModel.getFrequency());
                detail.setFec(transponderModel.getFec());
                detail.setModulationDetail(transponderModel.getModulationDetail());
                detail.setPolaraization(transponderModel.getPolaraization());
                detail.setSatellite(transponderModel.getSatellite());
                detail.setSymbolRate(transponderModel.getSymbolRate());
                transponderDetails.add(detail);
            }
        }

        if (transponderDetails != null && transponderDetails.size() > 0) {
            lvDetail = (ListView) findViewById(R.id.lvRechargePlan);
            SixthTransponderDetailScreenListViewAdapter adapter = new SixthTransponderDetailScreenListViewAdapter(
                    transponderDetails, SixthTransponderDetailScreenActivity.this);
            lvDetail.setAdapter(adapter);
            adapter.notifyDataSetChanged();
        } else {

            lvDetail = (ListView) findViewById(R.id.lvRechargePlan);
            txtEmpty = (TextView) findViewById(R.id.txtEmpty);
            txtEmpty.setVisibility(View.VISIBLE);
            lvDetail.setVisibility(View.GONE);
        }

        setupAdmob();
        share();
    }

    @Override
    protected void onResume() {
        // TODO Auto-generated method stub
        super.onResume();
    }

    @Override
    protected void onPause() {
        // TODO Auto-generated method stub
        super.onPause();
    }
    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        super.onClick(v);
        switch (v.getId()) {
        case R.id.backbtn:
            this.onBackPressed();
            break;
        }
    }
}
